/*
 *    Copyright (c) 2018-2025, boss All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the boss developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: boss
 */

package com.hopes.bizz.video.service.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hopes.bizz.video.common.constant.enums.VideoModDictEnum;
import com.hopes.bizz.video.common.constant.enums.VideoSysDictEnum;
import com.hopes.boss.admin.api.entity.SysDictItem;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.admin.api.resolver.enums.SysDictEnum;
import com.hopes.boss.common.entity.BaseLogicEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Optional;

/**
 * 视频
 *
 * @author daijie
 * @date 2023-10-24 13:58:52
 */
@Data
@TableName(value = "video_list", excludeProperty = "tenantId")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "视频")
public class VideoListEntity extends BaseLogicEntity {

    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(type = IdType.ASSIGN_ID)
    @Schema(description = "id")
    private Long id;

    /**
     * 视频标签
     */
    @Schema(description = "视频标签")
    private String videoTags;

    /**
     * 视频名称
     */
    @Schema(description = "视频名称")
    private String name;

    /**
     * 视频编码
     */
    @Schema(description = "视频编码")
    private String videoCode;

    /**
     * 视频分类
     */
    @Schema(description = "视频分类")
    private String videoType;

    /**
     * 关联ID
     */
    @Schema(description = "关联ID")
    private Long linkId;

    /**
     * 企业标识
     */
    @Schema(description = "企业标识")
    private Long companyId;

    /**
     * 区域索引
     */
    @Schema(description = "区域索引")
    private String regionIndex;

    /**
     * 定位
     */
    @Schema(description = "定位")
    private String location;

    /**
     * 图片
     */
    @Schema(description = "图片")
    private String img;

    /**
     * 是否启用
     */
    @Schema(description = "是否启用")
    private String useFlag;

    /**
     * 是否首页展示
     */
    @Schema(description = "是否首页展示")
    private String showIndexFlag;

    /**
     * 排序
     */
    @Schema(description = "排序")
    private Integer sortNum;

    /**
     * 备注
     */
    @Schema(description = "备注")
    private String remark;

    public String getVideoTagsStr() {
        return DictResolver.getItemLabelByValue(VideoSysDictEnum.video_tags, this.getVideoTags());
    }

    public String getRegionIndexStr() {
        return Optional.ofNullable(DictResolver.getItemByFieldValue(VideoModDictEnum.video_region, SysDictItem::getExt1, this.getRegionIndex())).map(SysDictItem::getName).orElse(null);
    }

    public String getUseFlagStr() {
        return DictResolver.getItemLabelByValue(SysDictEnum.yes_no_type, this.getUseFlag());
    }

    public String getShowIndexFlagStr() {
        return DictResolver.getItemLabelByValue(SysDictEnum.yes_no_type, this.getShowIndexFlag());
    }
}
